package com.globallogic.oopbasics.competence.comparator;

import java.util.Comparator;

import com.globallogic.oopbasics.competence.entity.AbstractCompetency;

/**
 * @author olena.strelchuk
 */

/**
 * Comparator class to compare Competencies in TotalCompetence by their Value
 */
public class ValueComparator implements Comparator<AbstractCompetency> {

	private static final int DOUBLE_FOUR_DIGITS_ROUNDING = 10000;

	/*
	 * Method compares Competencies in TotalCompetence according to their Value.
	 * 
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	@Override
	public int compare(AbstractCompetency competencyFirst,
			AbstractCompetency competencySecond) {
		return (int) Math
				.floor((competencyFirst.getGlobalValue() * DOUBLE_FOUR_DIGITS_ROUNDING - competencySecond
						.getGlobalValue() * DOUBLE_FOUR_DIGITS_ROUNDING));
	}

}
